package com.chenxi.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

import javax.servlet.http.HttpServletResponse;

public class MyPostFilter extends ZuulFilter {
    private static final String X_FRAME_OPTIONS = "SAMEORIGIN";
    @Override
    public String filterType() {
        return "post";
    }

    @Override
    public int filterOrder() {
        return 8;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() {
        RequestContext ctx = RequestContext.getCurrentContext();
        HttpServletResponse response = ctx.getResponse();
        response.setHeader("X-Frame-Options",X_FRAME_OPTIONS);
        ctx.setResponse(response);
        return null;
    }
}
